<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @cancel="visible = false"
    cancelText="关闭"
    :footer="null"
  >
    <a-card :bordered="false">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button type="primary" icon="download" @click="handleExportXls('库存历史信息表')">导出</a-button> -->
      </div>

      <!-- table区域-begin -->
      <div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
        >
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
            <img
              v-else
              :src="getImgView(text)"
              height="25px"
              alt=""
              style="max-width: 80px; font-size: 12px; font-style: italic"
            />
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
            <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="uploadFile(text)">
              下载
            </a-button>
          </template>

        </a-table>
      </div>
    </a-card>
  </j-modal>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'CrmInventoryHistoryList',
  mixins: [JeecgListMixin, mixinDevice],
  data() {
    return {
      title: '库存历史记录',
      width: 1200,
      visible: false,
      description: '库存历史信息表管理页面',
      queryParam: {
        id: ''
      },
      /* 分页参数 */
      otherPagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '库存编号',
          align: 'center',
          sorter: (a, b) => a.inventoryId - b.inventoryId,
          dataIndex: 'inventoryId',
        },
        {
          title: '已使用冷冻',
          align: 'center',
          sorter: (a, b) => a.physicalFreeze - b.physicalFreeze,
          dataIndex: 'physicalFreeze',
        },
        {
          title: '已使用冷藏',
          align: 'center',
          sorter: (a, b) => a.physicalRefrigerate - b.physicalRefrigerate,
          dataIndex: 'physicalRefrigerate',
        },
        {
          title: '已使用恒温',
          align: 'center',
          sorter: (a, b) => a.physicalConstant - b.physicalConstant,
          dataIndex: 'physicalConstant',
        },
        {
          title: '已使用常温',
          align: 'center',
          sorter: (a, b) => a.physicalNormal - b.physicalNormal,
          dataIndex: 'physicalNormal',
        },
        {
          title: '备注',
          align: 'center',
          sorter: (a, b) => a.remark - b.remark,
          dataIndex: 'remark',
        },
        {
          title: '创建人',
          align: 'center',
          sorter: (a, b) => a.createUserId - b.createUserId,
          dataIndex: 'createUserId',
        },
        {
          title: '创建时间',
          align: 'center',
          sorter: (a, b) => a.createTime - b.createTime,
          dataIndex: 'createTime',
        },
      ],
      url: {
        list: '/online/api/listCrmInventoryHistory',
        delete: '/online/api/deleteCrmInventoryHistory',
        deleteBatch: '/online/api/deleteCrmInventoryHistoryBatch',
      },
      dictOptions: {},
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
